﻿using System;
using System.Configuration;
using MvcApplicationDataHound.TSD_Mappings;

namespace MvcApplicationDataHound.Mappings
{
    public class PP_ConsumeFile
    {
        public void TestOne()
            {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var make = new Make
                        {
                            Name = "Ford"
                        };
                    session.Save(make);
                    transaction.Commit();
                }
            }
        }

        public void TestTwo()
        {
        //////
        // Create a PetaPoco database object


            //var db = new PetaPoco.Database(ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString);
            var db = new PetaPoco.Database("TestDB");  //overwridden to fix PetaPoco.cs

            // Insert a record
            var a = new article();
            a.title = "My new article";
            a.content = "PetaPoco was here";
            a.date_created = DateTime.UtcNow;
            db.Insert(a);

            // Update it
            a.content = "Blah blah";
            db.Update(a);
        }

        // Represents a record in the "articles" table
        public class article
        {
            public long article_id { get; set; }
            public string title { get; set; }
            public DateTime date_created { get; set; }
            public bool draft { get; set; }
            public string content { get; set; }
        }
    }
}